home *** CD-ROM | disk | FTP | other *** search
/ How to Get Online 1996 Spring / HOW2GON.ISO / mac / FTP / Robert's File Server v1. folder / Robert's File Server v1.10 / For Eudora 1.4.2 / File server.txt next >
Text File  |  1995-04-03  |  6KB  |  152 lines

  1. set pubdir to "Mac+:Fichiers:" -- the folder whare the files are
  2. set indexFile to {alias "Mac+:Fichiers:00index.txt"} -- the files list
  3. set inMailbox to "Entrée" -- the name of the incomming mailbox
  4. set trashMailbox to "Reçus et traités" -- the name of the trash mailbox we want to use
  5. set outMailbox to "Sortie" -- the name of the outgoing messages
  6. set formsMailbox to "Modèles" -- the name of our forms mailbox
  7. set sysop to "robert" -- who will get the Bcc of error reports if any
  8. set returnPath to "" as string -- initialize
  9. set myType to 2 -- 0 = AppleDouble, 2 = BinHex
  10.  
  11. tell application "Eudora F1.4.2"
  12.     activate
  13.     -- If not using the default Eudora's Settings open it here
  14.     with timeout of 3600 seconds
  15.         -- get the messages from server
  16.         connect with check
  17.         -- do we have incomming messages?
  18.         set messageCount to (count mailbox named inMailbox of mail folder named "" ¬
  19.             each message)
  20.         if messageCount is not 0 then
  21.             -- so process them
  22.             set itemNumber to 1
  23.             repeat messageCount times
  24.                 -- get the body of the message
  25.                 set messageText to (field "" of message itemNumber ¬
  26.                     of mailbox inMailbox of mail folder named "")
  27.                 set mesageText to messageText as text
  28.                 set lineCount to (count the paragraphs of messageText)
  29.                 set lineTodo to 1
  30.                 -- process each line
  31.                 repeat lineCount times
  32.                     set theLine to paragraph lineTodo of messageText
  33.                     set wordCount to (count the words of theLine)
  34.                     if wordCount is not 0 then
  35.                         set myCommand to the first word of theLine
  36.                         if (myCommand is "path") and (wordCount > 1) then
  37.                             set returnPath to characters 6 thru (the ¬
  38.                                 length of theLine) of theLine as string
  39.                         else if myCommand is "AppleDouble" then
  40.                             set myType to 0
  41.                         else if myCommand is "BinHex" then
  42.                             set myType to 2
  43.                         else if (myCommand is "help") ¬
  44.                             or (myCommand is "aide") then
  45.                             -- Instead of attaching a file, we get
  46.                             -- the content of a saved message and paste
  47.                             -- it into the reply.
  48.                             reply message itemNumber of mailbox inMailbox ¬
  49.                                 of mail folder named "" without quotetext
  50.                             if returnPath is not "" then
  51.                                 set field "To:" of message named "" to returnPath
  52.                             end if
  53.                             set the field "Subject:" of message named "" to myCommand
  54.                             -- now get the body of the saved message
  55.                             -- first locate the message itself
  56.                             set foundForm to 1
  57.                             repeat (count mailbox named formsMailbox ¬
  58.                                 of mail folder named "" each message) times
  59.                                 if the field "Subject:" of message foundForm ¬
  60.                                     of mailbox formsMailbox of mail folder "" ¬
  61.                                     contains myCommand then
  62.                                     exit repeat
  63.                                 else
  64.                                     set foundForm to foundForm + 1
  65.                                 end if
  66.                             end repeat
  67.                             -- get the body
  68.                             set myForm to field "" ¬
  69.                                 of (message foundForm of ¬
  70.                                 mailbox named formsMailbox of mail folder "")
  71.                             -- paste it
  72.                             set the field "" of message named "" to myForm
  73.                             -- send the message
  74.                             queue message named ""
  75.                         else if myCommand is "index" then
  76.                             -- send the "00index.txt" file
  77.                             reply message itemNumber of mailbox inMailbox ¬
  78.                                 of mail folder named "" without quotetext
  79.                             if returnPath is not "" then
  80.                                 set field "To:" of message named "" to returnPath
  81.                             end if
  82.                             set the field "Subject:" of message named "" to "Index"
  83.                             set the field "" of message named "" ¬
  84.                                 to ("This is the files list of our file server." ¬
  85.                                 & return & return ¬
  86.                                 & "To receive the help file, put the word «help»" ¬
  87.                                 & " in the body of your message." & return)
  88.                             set AttachType of message named "" to myType
  89.                             attach message named "" documentlist indexFile
  90.                             queue message named ""
  91.                         else if (myCommand is "send") and (wordCount > 1) then
  92.                             -- send a file
  93.                             reply message itemNumber of mailbox inMailbox ¬
  94.                                 of mail folder named "" without quotetext
  95.                             if returnPath is not "" then
  96.                                 set field "To:" of message named "" to returnPath
  97.                             end if
  98.                             -- get the file name
  99.                             set fName to characters 6 thru (the length of theLine) ¬
  100.                                 of theLine as string
  101.                             set field "Subject:" of message named "" to fName
  102.                             set the field "" of message named "" ¬
  103.                                 to "This is the file you requested." & return & return ¬
  104.                                 & "To receive the help file, put the word «help»" ¬
  105.                                 & " in the body of your message, to receive our files list, " ¬
  106.                                 & "put the word «index»." & return
  107.                             try
  108.                                 -- try to attach the file
  109.                                 set AttachType of message named "" to myType
  110.                                 attach message named "" documentlist {alias (pubdir & fName)}
  111.                             on error errorText
  112.                                 -- the file wasn't there???
  113.                                 set the field "" of message named "" ¬
  114.                                     to "Error while processing the «send» command for the file: «" ¬
  115.                                     & fName & "», probably because the file doesn't exists." & return ¬
  116.                                     & return & "To receive the help file, put the word «help»" ¬
  117.                                     & " in the body of your message, to receive our files list, " ¬
  118.                                     & "put the word «index»." & return & return ¬
  119.                                     & "The message returned by AppleScript: " & errorText & return
  120.                                 set the field "Bcc:" of message named "" to sysop
  121.                             end try
  122.                             queue message named ""
  123.                         end if
  124.                     end if
  125.                     set lineTodo to lineTodo + 1
  126.                 end repeat
  127.                 -- re-initialize variables
  128.                 set returnPath to "" as string
  129.                 set myType to 2
  130.                 set itemNumber to itemNumber + 1
  131.             end repeat
  132.             -- move messages to our trash mailbox
  133.             repeat messageCount times
  134.                 move message 1 of mailbox inMailbox of mail folder named "" ¬
  135.                     inserthere end of mailbox trashMailbox of mail folder named ""
  136.             end repeat
  137.             -- the same for sent messages
  138.             -- after sending them
  139.             set messageCount to (count mailbox named outMailbox ¬
  140.                 of mail folder named "" each message)
  141.             if (messageCount > 0) then
  142.                 connect with send
  143.                 repeat messageCount times
  144.                     move message 1 of mailbox outMailbox of mail folder named "" ¬
  145.                         inserthere end of mailbox trashMailbox of mail folder named ""
  146.                 end repeat
  147.             end if
  148.         end if
  149.         quit -- Bye
  150.     end timeout
  151. end tell
  152.